/**
 * <copyright>
 * </copyright>
 *

 */
package it.spoli.talkMe.impl;

import it.spoli.talkMe.Dispatch;
import it.spoli.talkMe.Interaction;
import it.spoli.talkMe.Invitation;
import it.spoli.talkMe.Message;
import it.spoli.talkMe.Protocol;
import it.spoli.talkMe.Request;
import it.spoli.talkMe.Subject;
import it.spoli.talkMe.Support;
import it.spoli.talkMe.TalkMeFactory;
import it.spoli.talkMe.TalkMePackage;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class TalkMeFactoryImpl extends EFactoryImpl implements TalkMeFactory
{
  /**
   * Creates the default factory implementation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public static TalkMeFactory init()
  {
    try
    {
      TalkMeFactory theTalkMeFactory = (TalkMeFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.spoli.it/TalkMe"); 
      if (theTalkMeFactory != null)
      {
        return theTalkMeFactory;
      }
    }
    catch (Exception exception)
    {
      EcorePlugin.INSTANCE.log(exception);
    }
    return new TalkMeFactoryImpl();
  }

  /**
   * Creates an instance of the factory.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TalkMeFactoryImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EObject create(EClass eClass)
  {
    switch (eClass.getClassifierID())
    {
      case TalkMePackage.SYSTEM: return createSystem();
      case TalkMePackage.PACKAGE: return createPackage();
      case TalkMePackage.MESSAGE: return createMessage();
      case TalkMePackage.DISPATCH: return createDispatch();
      case TalkMePackage.INVITATION: return createInvitation();
      case TalkMePackage.REQUEST: return createRequest();
      case TalkMePackage.SUBJECT: return createSubject();
      case TalkMePackage.INTERACTION: return createInteraction();
      case TalkMePackage.SUPPORT: return createSupport();
      default:
        throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object createFromString(EDataType eDataType, String initialValue)
  {
    switch (eDataType.getClassifierID())
    {
      case TalkMePackage.PROTOCOL:
        return createProtocolFromString(eDataType, initialValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String convertToString(EDataType eDataType, Object instanceValue)
  {
    switch (eDataType.getClassifierID())
    {
      case TalkMePackage.PROTOCOL:
        return convertProtocolToString(eDataType, instanceValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public it.spoli.talkMe.System createSystem()
  {
    SystemImpl system = new SystemImpl();
    return system;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public it.spoli.talkMe.Package createPackage()
  {
    PackageImpl package_ = new PackageImpl();
    return package_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Message createMessage()
  {
    MessageImpl message = new MessageImpl();
    return message;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Dispatch createDispatch()
  {
    DispatchImpl dispatch = new DispatchImpl();
    return dispatch;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Invitation createInvitation()
  {
    InvitationImpl invitation = new InvitationImpl();
    return invitation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Request createRequest()
  {
    RequestImpl request = new RequestImpl();
    return request;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Subject createSubject()
  {
    SubjectImpl subject = new SubjectImpl();
    return subject;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Interaction createInteraction()
  {
    InteractionImpl interaction = new InteractionImpl();
    return interaction;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Support createSupport()
  {
    SupportImpl support = new SupportImpl();
    return support;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Protocol createProtocolFromString(EDataType eDataType, String initialValue)
  {
    Protocol result = Protocol.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertProtocolToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TalkMePackage getTalkMePackage()
  {
    return (TalkMePackage)getEPackage();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @deprecated
   * @generated
   */
  @Deprecated
  public static TalkMePackage getPackage()
  {
    return TalkMePackage.eINSTANCE;
  }

} //TalkMeFactoryImpl
